<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/1/17
 * Time: 14:06
 */

namespace common\helpers;

use common\models\kingdee\HrPersonPhoto;
use common\result\ActionResult;
use Yii;
use common\consts\CommonResources;
use common\models\kingdee\Person;

class KdPersonHelper
{
    public static function getPersonPhotoContent($personId){
        $person = Person::findOne($personId);

        if (!$person){
            $failReason = CommonResources::ACTION_NAME_MODEL_FAIL('Get', 'Person Content', $personId);
            $errMsg = CommonResources::ACTION_FAIL_MSG('Upload', 'File', $failReason);
            Yii::error($errMsg);
            return new ActionResult(false, $errMsg);
        }

        $employee_number = $person->FNUMBER;
        $employee_name = $person->FNAME_L2;

        $personPhoto = HrPersonPhoto::findOne([
            'FPERSONID' => $personId
        ]);
        if (!$personPhoto){
            $failReason = CommonResources::ACTION_NAME_MODEL_FAIL_WITH_REASON('Get', 'Person Content', $personId, 'PersonPhoto Not Found');
            $errMsg = CommonResources::ACTION_FAIL_MSG('Upload', 'File', $failReason);
            Yii::error($errMsg);
            return new ActionResult(false, $errMsg);
        }


    }
}